package com.demo.common.config;


import com.demo.common.plugin.EnjoySqlPlugin;
import com.jfinal.template.activerecord.PageSqlKit;
import com.jfinal.template.activerecord.SqlPara;
import com.jfinal.template.activerecord.SqlUtil;
import com.jfinal.template.kit.Kv;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class EnjoySqlTest {

    public static void main(String[] args) {
        new EnjoySqlPlugin().start();

        List list = new ArrayList();
        list.add(2);
        list.add(5);
        String ids = StringUtils.join(list.toArray(), ",");

        Kv kv = new Kv();
        kv.set("ids", ids);
        kv.set("title", "test");
        kv.set("content", "test 1");
        SqlPara sqlPara = SqlUtil.getSqlPara("blog.queryList",kv);
//        System.out.println(sqlPara);
        String[] sql = PageSqlKit.parsePageSql(sqlPara.getSql());
        System.out.println("select:"+sql[0]);
        System.out.println("select:"+sql[1]);
        System.out.println(sqlPara);
    }
}
